import { useRef, useState } from 'react'
function MyRef() {
    const inputRef = useRef(null);
    const [value, setValue] = useState('')
    const handleClick = () => {
        console.log(value)
        inputRef.current.focus()
    }
    return <div>
        <input ref={inputRef} value={value} onChange={(e) => setValue(e.target.value)} />
        <button onClick={handleClick}>点我聚焦</button>
    </div>
}

export default MyRef;